AC_INIT([ppm], [1.0])
AC_PREFIX_DEFAULT([$HOME])

AC_CANONICAL_TARGET([])
AC_MSG_CHECKING([Host])
AC_MSG_RESULT([$host])

AM_INIT_AUTOMAKE([-Wall -Werror foreign])

dnl save $CXXFLAGS since AC_PROG_CC likes to insert "-g -O2"
dnl if $CXXFLAGS is blank
cxxflags_save="$CXXFLAGS"
AC_PROG_CC
AC_PROG_CXX
CXXFLAGS="$cxxflags_save"

dnl x86_64-redhat-linux-gnu
cxxflags_save="$CXXFLAGS"
if test -z "$GCC"; then
        case $host in 
        sparc-sun-solaris*)
                CXXFLAGS="-w" ;;
        esac
else
        AC_MSG_RESULT([$GCC_VERSION])
        AC_MSG_CHECKING([Host])
        AC_MSG_RESULT([$host])
        case $host in
        *64-*-linux*)
                CXXFLAGS="-g -w -ansi -m64" ;;
        *86-*-linux*)
                CXXFLAGS="-g -w -ansi -m32" ;;
        esac
fi
CXXFLAGS="$CXXFLAGS $cxxflags_save"


AC_CHECK_PROG([CCACHE],[ccache],[ccache],[])
if test "x${CCACHE}" = "xccache" ;then
 CC="$CCACHE $CC"
 CXX="$CCACHE $CXX"
fi


AC_PROG_LIBTOOL
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
  Makefile
  domain/Makefile
  domain/ppmprocord/Makefile
  domain/ppmtask/Makefile
  ppm/Makefile
  ppm_table/Makefile
])
AC_OUTPUT